package com.guigu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.guigu.mapper.OrderPaymentMapper;
import com.guigu.pojo.OrderPayment;
import com.guigu.service.OrderPaymentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 订单支付记录表 服务实现类
 * </p>
 *
 * @author Mr.Zhang
 * @since 2025-03-12
 */
@Service
public class OrderPaymentServiceImpl extends ServiceImpl<OrderPaymentMapper, OrderPayment> implements OrderPaymentService {

    @Autowired
    private OrderPaymentMapper orderPaymentMapper;

    @Override
    public OrderPayment getOneByOrderId(Integer orderId) {
        QueryWrapper<OrderPayment> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("order_id",orderId);
        if (orderPaymentMapper.selectOne(queryWrapper)!=null){
            return orderPaymentMapper.selectOne(queryWrapper);
        }
        return null;
    }

    @Override
    public OrderPayment getOneByOrderNumber(String orderNumber) {
        QueryWrapper<OrderPayment> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("order_id",orderNumber);
        if (orderPaymentMapper.selectOne(queryWrapper)!=null){
            return orderPaymentMapper.selectOne(queryWrapper);
        }
        return null;
    }
}
